A Java Extension with Support for Dimensions

نویسنده

  • André van Delft
چکیده

double*Speed divide (double*Length, double*Time); The original Java language specification defines: The signature of a method consists of the name of the method and the number and types of formal parameters to the method.. This definition does not change; hence a method signature does not contain dimension specifiers of the formal parameters. Instead the dimension specifiers constitute a rather independent dimension signature for the method. An unchanged rule from the Java language specification is: A class may not declare two methods with the same signature, or a compile-time error occurs. So adding another divide method with different dimensions would cause a function already defined error: abstract double*Acceleration divide(double*Speed, double*Time);//errordouble*Acceleration divide(double*Speed, double*Time);//error Instance methods may override others in superclasses and interfaces that have equal method signatures. A notable restriction is that the return types are equal. An extra restriction is now that the dimension signatures are equal, as well as the dimension specifiers of the return types. Java’s original resolution rules for method calls involve the following compile-time steps: 1. Determine Class or Interface to Search 2. Determine Method Signature 2.1 Find Methods that are Applicable and Accessible 2.2 Choose the Most Specific Method 3. Is the Chosen Method Appropriate Step 2 involves only parameter types, not the return types, and not the dimension specifiers. Step 3 has checks dealing with staticness; it also requires that a void method may only be called in a top level expression. In this step, an extra requirement is now that the dimensions of the formal and actual parameters match. Expressions Expressions must be dimensionally consistent. Both sides of assignments, additions and subtractions must have equal dimensions. Multiplications and divisions result in appropriate dimensions: double * Time t; double * Length s; double * Speed v; t = 18.3*second; // t = 18.3; would be a compile error s = 26.4*meter; // s = 26.4; would be a compile error v = t/s;

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Automating Delegation in Class-Based Languages

Some designers of class-based object oriented languages choose not to support multiple inheritance. As a result, programmers often resort to ad hoc workarounds. The most common of these workarounds is delegation. Even delegation is tedious and error prone, however: We believe that language designers who choose against multiple inheritance should consider automating delegation in order to allevi...

متن کامل

Decouplink: Dynamic Links for Java

Software entities should be open for extension, but closed to modification. Unfortunately, unanticipated requirements emerging during software evolution makes it difficult to always enforce this principle. This situation poses a dilemma that is particularly important when considering component-based systems: On the one hand, violating the open/closed principle by allowing for modification compr...

متن کامل

Efficient Implementation of Run-time Generic Types for Java

We describe an efficient compiler and run-time system for NextGen, a compatible extension of the Java programming language supporting run-time generic types designed by Cartwright and Steele. The resulting system is comparable in performance with both standard Java and the GJ extension of Java, which does not support run-time generic types. Our implementation of NextGen consists of a compiler e...

متن کامل

Java Modular Extension for Operator Overloading

The paper introduces a modular extension (plugin) for Java language compilers and Integrated Development Environments (IDE) which adds operator overloading feature to Java language while preserving backward compatibility. The extension use the idea of library-based language extensibility similar to SugarJ[1]. But unlike most language extensions, it works directly inside the compiler and does no...

متن کامل

EventJava: An Extension of Java for Event Correlation

Event correlation has become the cornerstone of many reactive applications, particularly in distributed systems. However, support for programming with complex events is still rather specific and rudimentary. This paper presents EventJava, an extension of Java with generic support for event-based distributed programming. EventJava seamlessly integrates events with methods, and broadcasting with ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Softw., Pract. Exper.

دوره 29  شماره 

صفحات  -

تاریخ انتشار 1999